package com.wanhe.mealbookmodule.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.wanhe.base.model.disgn.PageViewModel;
import com.wanhe.mealbookmodule.views.MealBookPageItemView;

/**
 * Created by cdj on 2017/6/22.
 */

public class MealBookPagerAdapter extends CommonBasePagerAdapter<PageViewModel> {
    public MealBookPagerAdapter(Context context) {
        super(context);
    }

    @Override
    protected View genarateView(Context context, ViewGroup container, int position) {
        PageViewModel itemAtPosition = getItemAtPosition(position);
        MealBookPageItemView itemView = new MealBookPageItemView(context);
        itemView.initData(itemAtPosition);
        itemView.setPageIndex(position);
        return itemView;
    }

    public int getPagePositionWithTypeID(int tid) {
        int tidPagePosition = 0;
        int count = getCount();
        for (int i = 0; i < count; i++) {
            int tid1 = mList.get(i).getTid();
            if (tid1 == tid){
                tidPagePosition = i;
                break;
            }
        }
        return tidPagePosition;
    }
}
